package com.runda.task;

import java.io.File;

import com.aliyun.oss.OSSClient;

/**
 * 阿里云oss  file文件上传
 * @author Administrator
 *
 */
public class AliyunOssUploadFromFile extends Thread {
	private String endpoint;
	private String accessKeyId;
	private String accessKeySecret;
	private String key;
	private String bucket;
	private File file;
	private String id;
	private String cdnpath;
	//private ResourceService resourceservice;
	@Override
	public void run() {
		try {
			// 创建OSSClient实例
			OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
			// 上传文件
			ossClient.putObject(bucket, key, file);
			// 关闭client
			ossClient.shutdown();
		    /*com.rundatop.biz.resource.domain.Resource resource = new com.rundatop.biz.resource.domain.Resource();
		    resource.setId(this.id);
		    resource.setPath(this.key);
		    resourceservice.updateResource(resource);*/
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public AliyunOssUploadFromFile(String endpoint, String accessKeyId, String accessKeySecret, String key, String id,
			String bucket, String cdnpath, File file) {
		super();
		this.endpoint = endpoint;
		this.accessKeyId = accessKeyId;
		this.accessKeySecret = accessKeySecret;
		this.key = key;
		this.id = id;
		this.bucket = bucket;
		this.cdnpath = cdnpath;
		this.file = file;
	}
	
	
}
